
/**
 * create by Alec
 */
import React, { Component, PureComponent } from "react";
import PropTypes from "prop-types";
import "./index.less"
import { Icon } from "@ali/ding-ui";

class DateRange extends Component {
    constructor(props) {
        super(props);
    }

    static defaultProps = {};

    static propTypes = {
        dateRange: PropTypes.object, // 时间参数
    };
    render() {
        const { currentMonth = {}, 
                lastMonth = {}, 
                nextMonth = {},  
                currentWeek = {}, 
                lastWeek = {}, 
                nextWeek = {}, 
                periodType = '' } = this.props.dateRange || {};
        const lastTime = (periodType === 'month' ? lastMonth : lastWeek);
        const currentTime = (periodType === 'month' ? currentMonth : currentWeek);
        const nextTime = (periodType === 'month' ? nextMonth : nextWeek);
        return (
            <div className="date-range-container2">
                <div className="date-range">
                    <span className={`left ${!lastTime.value && 'disabled'}`} onClick={ () => {
                        window._rlog(`_stat_arrow_${periodType}_left`);
                        this.props.onLeftClick(lastTime.value) 
                    }}>
                        <Icon type="left" />
                    </span>
                
                    <span className="center">
                        {currentTime.showValue}
                    </span>
                
                    <span className={`right ${!nextTime.value && 'disabled'}`} onClick={ () => {
                        window._rlog(`_stat_arrow_${periodType}_right`);
                        this.props.onRightClick(nextTime.value) }
                    }>
                        <Icon type="right" />
                    </span>
                    
                </div>
            </div>
        )
    }
}

export default DateRange;
